package com.t3.animation
{
	import com.t3.animation.AnimatedObject;
	import flash.geom.Point;
	import flash.utils.IExternalizable;
	import flash.utils.IDataInput;
	import flash.utils.IDataOutput;
	import flash.net.registerClassAlias;

	public class Sketchline implements AnimatedObject, IExternalizable 
	{
		private var _points:Array;
		private var _color:Number;
		
		public function Sketchline()
		{
			registerClassAlias("com.t3.animation.Sketchline", Sketchline);
		}
		
		public function init( color:Number, points:Array ) : void
		{
			_color = color;
			_points = points;
		}

		public function get points():Array
		{
			return _points;
		}
		
		public function get color():Number
		{
			return _color;
		}
		
		public function writeExternal(output:IDataOutput):void 
		{
			output.writeInt(this._color);
			output.writeObject(this._points);
		}

		public function readExternal(input:IDataInput):void
		{
			this._color = input.readInt();
			var ar:Array = input.readObject();
			this._points = new Array();
			
			for ( var a:uint = 0 ; a < ar.length; a++ )
			{
				var p:Point = new Point( ar[a].x, ar[a].y );
				
				this._points.push( p );
			}
		}
		
		public static function prepare():void
		{
			var v:Sketchline = new Sketchline();
			v.init( 123, new Array() );
			v = null;
		}
	}
}